home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_1.zip / INSTALL.CMD < prev    next >
OS/2 REXX Batch file  |  1992-11-16  |  22KB  |  679 lines

  1.     SET TTHRU OFF        ; Must be 1st line to suppress typethrough
  2.     ON ESCAPE GOSUB Escape    ; Exit if ESC
  3. ;****    TRACE ON        ; Debugging
  4. ;
  5. ; ----- COM-AND INSTALL script for automatic execution
  6. ;    Commenced: 10/90 R.McG
  7. ; -----------------------------------------------------------------------
  8. ;    Purpose:
  9. ;       This script, named INSTALL.CMD, is executed automatically by
  10. ;    COM-AND after the load-time creation of the DFT file.  It may be
  11. ;    manually invoked through the F2 window at any time, as well.
  12. ; -----------------------------------------------------------------------
  13. ;
  14. ;    Initialization
  15. ;
  16.     LEGEND "Welcome..."
  17.     SET RDISP OFF        ; Ignore received chars
  18. ;
  19. ;    Establish a DWINDOW, and change the text display to window default.
  20. ;    .. Save the previous text display attribute, for restoration later.
  21. ;
  22.     DWIND 1,2 22,78     ; Establish scrolling region
  23.     N99 = "_TEXT"           ; Save original text attr
  24.     SET TEXT "_DEFA"        ; Set text attr
  25. ;
  26. ;    Perform tasks
  27. ;
  28. Again:
  29.     GOSUB Intro        ; Paint intro screen
  30.     GOSUB Set        ; Look at autoexec file
  31.     GOSUB Port        ; Select port for default use
  32.     GOSUB Speed        ; Select speed for default use
  33.     GOSUB Type        ; Select modem type
  34.     GOSUB Update        ; Ending "do it again?" query
  35.     IF FAILED GOTO Again
  36. ;
  37. ;    Save current settings
  38. ;
  39.     SET TEXT N99        ; Reset text attr for store
  40.     STORE DEFAULT        ; Update defaults
  41.     GOTO Almost        ; Skip Escape tests
  42. ;
  43. ;    Escape was hit - if runtime invocation, do the CODA.
  44. ;
  45. Escape:
  46.     IF STRCMP "_RUNT" "NO" GOTO Exit
  47. ;
  48. ;    Last words
  49. ;
  50. Almost:
  51.     ON ESCAPE GOSUB EXIT    ; New ESC processor
  52.     SET TEXT "_DEFA"        ; Set text attr
  53.     GOSUB Coda        ; Ending last words
  54. ;
  55. ;    Exit the script
  56. ;
  57. Exit:
  58.     SET TEXT N99        ; Reset text attr finally
  59.     DWINDOW CLEAR        ; Clear any scrolling region
  60.     CLEAR            ; Clear entire text window
  61.     EXIT
  62. ;
  63. ; ----- Subroutine: Intro -> introductory screen
  64. ;    .. note: BOX instead of WOPEN is used - allowing global ESC
  65. ;
  66. Intro:
  67.     BOX   0,0 23,79 (default)
  68.     ATSAY 0,2 (default)   " INSTALL intro "
  69.     ATSAY 23,25 (default) " Press ESC to cancel INSTALL "
  70.     LOCATE 2,2
  71.  
  72.     MESS "   ▓▓▓▓▓▓▓▓  ▓▓▓▓▓▓▓▓  ▓▓▓   ▓▓▓             ▓▓▓▓▓▓▓  ▓▓     ▓▓  ▓▓▓▓▓▓▓  "
  73.     MESS "   ▓▓        ▓▓    ▓▓  ▓▓ ▓▓▓ ▓▓            ▓▓     ▓▓ ▓▓▓    ▓▓  ▓▓    ▓▓ "
  74.     MESS "   ▓▓        ▓▓    ▓▓  ▓▓  ▓  ▓▓            ▓▓     ▓▓ ▓▓ ▓   ▓▓  ▓▓    ▓▓ "
  75.     MESS "   ▓▓        ▓▓    ▓▓  ▓▓     ▓▓  ▓▓▓▓▓▓▓▓  ▓▓▓▓▓▓▓▓▓ ▓▓  ▓  ▓▓  ▓▓    ▓▓ "
  76.     MESS "   ▓▓        ▓▓    ▓▓  ▓▓     ▓▓            ▓▓     ▓▓ ▓▓   ▓ ▓▓  ▓▓    ▓▓ "
  77.     MESS "   ▓▓        ▓▓    ▓▓  ▓▓     ▓▓            ▓▓     ▓▓ ▓▓    ▓▓▓  ▓▓    ▓▓ "
  78.     MESS "   ▓▓▓▓▓▓▓▓  ▓▓▓▓▓▓▓▓  ▓▓     ▓▓            ▓▓     ▓▓ ▓▓     ▓▓  ▓▓▓▓▓▓▓  "
  79.     MESS " "
  80. ;
  81. ;    Add introductory text
  82. ;
  83.     IF STRCMP "_RUNT" "YES"
  84.        MESS "COM-AND has created a file named COM-AND.DFT for default values.  This means"
  85.        MESS "that this is the first time COM-AND has executed under these conditions.  A"
  86.        MESS "script (INSTALL.CMD) included with the COM-AND release will help install the"
  87.        MESS "settings you will use in this and subsequent COM-AND sessions."
  88.     ELSE
  89.        MESS "You have invoked INSTALL.CMD to change COM-AND's default settings.  INSTALL"
  90.        MESS "simplifies 1) adding/changing a COM-AND= environment variable to the AUTO-"
  91.        MESS "EXEC.BAT, 2) setting modem port and type, and 3) setting operating values"
  92.        MESS "for this and subsequent COM-AND sessions."
  93.     ENDIF
  94.     MESS " "
  95.     MESS "In order to use this script, you will need to know a few facts about your PC"
  96.     MESS "and its configuration.  You will need to know the boot drive, the modem port"
  97.     MESS "and the type of modem you will be using.  This script will help you decide"
  98.     MESS "these matters (as much as it is able) and change the DFT file accordingly."
  99.     MESS " "
  100.     MESS "You may skip this installation script by pressing ESC now (or anytime during"
  101.     MESS "the installation).  Press any other key to continue..."
  102. ;
  103. ;    Wait for a keypress
  104. ;
  105.     KEYGET S0        ; Wait for it
  106.     RETURN            ; And we're done
  107. ;
  108. ; ----- Subroutine: Set -> Inform of update autoexec.bat with COM-AND=
  109. ;
  110. Set:
  111.     ENVIRON S0 "COM-AND="   ; Look for pre-existing COM-AND= environ var
  112.     IF FOUND GOTO Already    ; If it exists, ask if its to be changed
  113. ;
  114. ;    Paint a screen
  115. ;
  116.     BOX   0,0 23,79 (default)
  117.     ATSAY 0,2 (default)   " Boot config "
  118.     ATSAY 23,25 (default) " Press ESC to cancel INSTALL "
  119.     LOCATE 2,2
  120.  
  121.     MESS "COM-AND works best if a single subdirectory is used for COM-AND files and"
  122.     MESS "scripts.  COM-AND is executing currently from the subdirectory: "
  123.     MESS " "
  124.     MESS "_SUBD"
  125.     MESS " "
  126.     MESS "COM-AND looks for files and scripts 1) in the subdirectory it finds at run-"
  127.     MESS "time, and if not there 2) in the subdirectory pointed out by the environment"
  128.     MESS "variable 'COM-AND='.  If COM-AND's working subdirectory is indicated by that"
  129.     MESS "environment variable, COM-AND may be executed in ANY subdirectory and still"
  130.     MESS "find scripts and files."
  131.     MESS " "
  132.     MESS "You may use this script to update your AUTOEXEC.BAT file to SET the environ-"
  133.     MESS "ment variable, or skip this step."
  134.     MESS " "
  135.     MESS "Select S)kip, U)pdate, or ESCape (escape cancels this script): "
  136. ;
  137. ;    Wait for a keypress
  138. ;
  139.     GET S0 1        ; Wait for a char
  140.     SWITCH S0        ; Switch on the return
  141.        CASE "S"             ; S)kip
  142.        ENDCASE
  143.        CASE "U"             ; U)pdate
  144.         GOSUB Autoexec    ; Do the update
  145.        ENDCASE
  146.        DEFAULT        ; Any other selection
  147.         SOUND 100,100
  148.         GOTO Set
  149.        ENDCASE
  150.     ENDSWITCH
  151.     RETURN            ; And continue
  152. ;
  153. ; ----- Error:    Open a window, display a message, and exit
  154. ;    S0 passes the error message
  155. ;
  156. Error:
  157.     WOPEN 10,10,12,70 (contrast)
  158.     ATSAY 10,12 (contrast) " Error "
  159.     ATSAY 11,12 (contrast) S0(0:55); Max msg width 55 chars
  160.     ATSAY 12,26 (contrast) " Press any key to continue "
  161.     ;
  162.     ;    Wait a keypress
  163.     ;
  164.     KEYGET S0            ; Wait for any key
  165.     WCLOSE
  166.     RETURN
  167. ;
  168. ; ----- Subroutine: Autoexec -> update autoexec.bat with COM-AND=
  169. ;
  170. Autoexec:
  171.     BOX   0,0 23,79 (default)
  172.     ATSAY 0,2 (default)   " AUTOEXEC update "
  173.     ATSAY 23,25 (default) " Press ESC to cancel INSTALL "
  174.     LOCATE 2,2
  175.  
  176.     MESS "Please enter the drive letter (A,B,C...) from which your PC is booted.  If"
  177.     MESS "a diskette is used for boot, please see that the boot disk is in that drive."
  178.     MESS " "
  179.     MESS "Select drive: A,B,C...: "
  180. ;
  181. ;    Wait for a keypress
  182. ;
  183.     GET S0 1        ; Wait for a char
  184.     IF NOT ALPHA S0
  185.        SOUND 100,100
  186.        GOTO Autoexec
  187.        ENDIF
  188. ;
  189. ;    Look for an autoexec.bat file on that drive
  190. ;
  191.     S1 = S0*":\AUTOEXEC.BAT"
  192.     IF ISFILE S1 GOTO Auto200
  193. ;
  194. ;    Missing autoexec.bat
  195. ;
  196.     MESS " "
  197.     MESS "No AUTOEXEC.BAT file was found on the indicated drive.  One will be created"
  198.     MESS "if you wish, or you may try another drive."
  199.     MESS " "
  200.     MESS "Select C)reate, A)nother-drive, or ESCape (escape cancels this script): "
  201. ;
  202. ;    Wait for a keypress
  203. ;
  204.     GET S0 1        ; Wait for a char
  205.     SWITCH S0        ; Switch on the return
  206.        CASE "C"             ; C)reate
  207.         GOTO AUTO100
  208.        ENDCASE
  209.        CASE "A"             ; A)nother
  210.         GOTO Autoexec    ; Do it again
  211.        ENDCASE
  212.        DEFAULT        ; Any other selection
  213.         SOUND 100,100
  214.         GOTO Autoexec
  215.        ENDCASE
  216.     ENDSWITCH
  217. ;
  218. ;    Create AUTOEXEC... get parameter for the subdirectory
  219. ;
  220. Auto100:
  221.     GOSUB GetSetVal
  222. ;
  223. ;    Create it
  224. ;
  225.     FOPENO S1 TEXT        ; Open for output
  226.     IF FAILED        ; If open failed
  227.        S0 = "Error opening "*S1
  228.        GOSUB Error
  229.        GOTO Autoexec
  230.        ENDIF
  231.     WRITE "SET COM-AND="*S0*"!"
  232.     WRITE "DATE!"
  233.     WRITE "TIME!"
  234.     WRITE "^Z"              ; ASCII EOF
  235.     FCLOSEO         ; Close it
  236.     RETURN            ; And we're done creating it
  237. ;
  238. ;    AUTOEXEC exists... append SET COM-AND= to the file
  239. ;    .. note: I don't test for the presence of SHELL or another COM-AND=
  240. ;
  241. Auto200:
  242.     GOSUB GetSetVal
  243. ;
  244. ;    Create it
  245. ;
  246.     FOPENO S1 TEXT APPEND    ; Open for output - appending at EOF
  247.     IF FAILED        ; If open failed
  248.        S0 = "Error opening "*S1
  249.        GOSUB Error
  250.        GOTO Autoexec
  251.        ENDIF
  252.     WRITE "SET COM-AND="*S0*"!"
  253.     WRITE "^Z"              ; ASCII EOF
  254.     FCLOSEO         ; Close it
  255.     RETURN            ; And we're done creating it
  256. ;
  257. ;    Subroutine: GetSETVal (S0 returns value)
  258. ;
  259. GetSetVal:
  260.     MESS "COM-AND is executing currently from the subdirectory: "
  261.     MESS